var zoom = null;

function closeZoom()
{
  zoom.dialog('close');
}

function openZoom(el)
{
  var img = $(el);

  zoom = $('<div><img src="' + img.attr('data-image') + '" width="' + img.attr('data-width') + '" height="' + img.attr('data-height') + '" onclick="closeZoom();" /></div>').dialog(
  {
    modal: true,
    draggable: false,
    resizable: false,
    width: parseInt(img.attr('data-width')) + 10,
    height: parseInt(img.attr('data-height')) + 10,
    dialogClass: 'zoomed',
    close: function()
    {
      $(this).remove();

      zoom = null;
    }
  });
}

function focusErroneousField()
{
	$('ul.errors').first().prev().focus();
}